<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>注册</title>
    <!-- bootstrap样式，地图插件使用 -->
    <link rel="stylesheet" href="../../css/bootstrap.min.css"/>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <!-- 样式 -->
    <link rel="stylesheet" href="../../css/style.css"/>
    <!-- 主题（主要颜色设置） -->
    <link rel="stylesheet" href="../../css/theme.css"/>
    <!-- 通用的css -->
    <link rel="stylesheet" href="../../css/common.css"/>
</head>
<style>
    html::after {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        content: '';
        display: block;
        background-attachment: fixed;
        background-size: cover;
        background-position: center;
        z-index: -1;
    }

    #swiper {
        overflow: hidden;
        margin: 0 auto;
    }

    #swiper .layui-carousel-ind li {
        width: 12px;
        height: 12px;
        border-width: 2px;
        border-style: solid;
        border-color: rgba(255, 255, 255, 1);
        border-radius: 30px;
        background-color: rgba(247, 247, 247, 0);
        box-shadow: ;
    }

    #swiper .layui-carousel-ind li.layui-this {
        width: 12px;
        height: 12px;
        border-width: 2px;
        border-style: solid;
        border-color: rgba(35, 183, 164, 1);
        border-radius: 30px;
        background-color: rgba(255, 255, 255, 0);
        box-shadow: ;
    }

    button, button:focus {
        outline: none;
    }

    .data-add-container .add .layui-select-title .layui-unselect {
        padding: 0 12px;
        height: 40px;
        font-size: 14px;
        color: #333;
        border-radius: 4px;
        border-width: 1px;
        border-style: solid;
        border-color: #DCDFE6;
        background-color: #fff;
        box-shadow: ;
        text-align: left;
    }

    .data-add-container .add .layui-form-item {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .data-add-container .layui-form-pane .layui-form-item[pane] .layui-form-label {
        margin: 0;
        position: inherit;
        background: transparent;
        border: 0;
    }

    .data-add-container .add .layui-input-block {
        margin: 0;
        flex: 1;
    }

    .data-add-container .layui-form-pane .layui-form-item[pane] .layui-input-inline {
        margin: 0;
        flex: 1;
        display: flex;
    }
</style>
<body style="background: #EEEEEE; ">


<div id="app">

    <!--
    <div class="layui-carousel" id="swiper">
        <div carousel-item id="swiper-item">
            <div v-for="(item,index) in swiperList" v-bind:key="index">
                <img class="swiper-item" :src="item.img">
            </div>
        </div>
    </div> -->
    <div class="layui-carousel" id="swiper"
         :style='{"width":"100%","boxShadow":"","margin":"0px auto 0 auto","borderRadius":"0px","borderStyle":"solid","borderWidth":"0"}'>
        <div carousel-item id="swiper-item">
            <div v-for="(item,index) in swiperList" :key="index">
                <img style="width: 100%;height: 100%;object-fit:cover;" :src="item.img"/>
            </div>
        </div>
    </div>
    <!-- 轮播图 -->

    <div class="data-add-container"
         :style='{"padding":"20px","boxShadow":"","margin":"30px auto","backgroundColor":"#fff","borderRadius":"10px","borderWidth":"0","borderStyle":"solid"}'>

        <form class="layui-form layui-form-pane add" lay-filter="myForm">

            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">测试编号：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.ceshibianhao" type="text" :readonly="ro.ceshibianhao" name="ceshibianhao"
                           id="ceshibianhao" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">测试名称：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.ceshimingcheng" type="text" :readonly="ro.ceshimingcheng"
                           name="ceshimingcheng" id="ceshimingcheng" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">用户名：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.yonghuming" type="text" :readonly="ro.yonghuming" name="yonghuming"
                           id="yonghuming" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">用户姓名：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.yonghuxingming" type="text" :readonly="ro.yonghuxingming"
                           name="yonghuxingming" id="yonghuxingming" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">回答1：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.huida1" type="text" :readonly="ro.huida1" name="huida1" id="huida1"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">回答2：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.huida2" type="text" :readonly="ro.huida2" name="huida2" id="huida2"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">回答3：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.huida3" type="text" :readonly="ro.huida3" name="huida3" id="huida3"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">回答4：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.huida4" type="text" :readonly="ro.huida4" name="huida4" id="huida4"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item" pane>
                <label :style='{"width":"94px","padding":"0 12px 0 0","fontSize":"14px","color":"#333","textAlign":"right"}'
                       class="layui-form-label">回答5：</label>
                <div class="layui-input-block">
                    <input :style='{"padding":"0 12px","boxShadow":"","borderColor":"#DCDFE6","backgroundColor":"#fff","color":"#333","borderRadius":"4px","textAlign":"left","borderWidth":"1px","fontSize":"14px","borderStyle":"solid","height":"40px"}'
                           v-model="detail.huida5" type="text" :readonly="ro.huida5" name="huida5" id="huida5"
                           autocomplete="off" class="layui-input">
                </div>
            </div>


            <div :style='{"padding":"10px","boxShadow":"","margin":"0 0 10px 0","backgroundColor":"#fff","borderRadius":"4px","borderWidth":"0px","borderStyle":"solid"}'
                 class="layui-form-item">
                <div class="layui-input-block" style="text-align: right;">
                    <button :style='{"padding":"0 10px","boxShadow":"","margin":"0 10px","borderColor":"#ccc","backgroundColor":"rgba(241, 56, 37, 1)","color":"#fff","borderRadius":"30px","borderWidth":"0","width":"25%","fontSize":"14px","borderStyle":"solid","height":"44px"}'
                            class="layui-btn btn-submit" lay-submit lay-filter="*">提交
                    </button>
                    <button :style='{"padding":"0 10px","boxShadow":"","margin":"0 10px","borderColor":"rgba(225, 230, 234, 1)","backgroundColor":"#fff","color":"red","borderRadius":"30px","borderWidth":"1px","width":"25%","fontSize":"14px","borderStyle":"solid","height":"44px"}'
                            type="reset" class="layui-btn layui-btn-primary">重置
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="../../layui/layui.js"></script>
<script src="../../js/vue.js"></script>
<script src="../../js/elementui.js"></script>
<!-- 组件配置信息 -->
<script src="../../js/config.js"></script>
<!-- 扩展插件配置信息 -->
<script src="../../modules/config.js"></script>
<!-- 工具方法 -->
<script src="../../js/utils.js"></script>
<!-- 校验格式工具类 -->
<script src="../../js/validate.js"></script>
<!-- 地图 -->
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=ca04cee7ac952691aa67a131e6f0cee0"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap.AMapPositionPicker.js"></script>
<script>
    var jquery = $;

    var vue = new Vue({
        el: '#app',
        data: {
            // 轮播图
            swiperList: [{
                img: '../../img/banner.jpg'
            }],
            dataList: [],
            ro: {
                ceshibianhao: false,
                ceshimingcheng: false,
                yonghuming: false,
                yonghuxingming: false,
                huida1: false,
                huida2: false,
                huida3: false,
                huida4: false,
                huida5: false,
            },
            detail: {
                ceshibianhao: genTradeNo(),
                ceshimingcheng: '',
                yonghuming: '',
                yonghuxingming: '',
                huida1: '',
                huida2: '',
                huida3: '',
                huida4: '',
                huida5: '',
            },
            centerMenu: centerMenu
        },
        updated: function () {
            layui.form.render('select', 'myForm');
        },
        computed: {},
        methods: {
            jump(url) {
                jump(url)
            }
        }
    })


    layui.use(['layer', 'element', 'carousel', 'http', 'jquery', 'form', 'upload', 'laydate', 'tinymce'], function () {
        var layer = layui.layer;
        var element = layui.element;
        var carousel = layui.carousel;
        var http = layui.http;
        var jquery = layui.jquery;
        var form = layui.form;
        var upload = layui.upload;
        var laydate = layui.laydate;
        var tinymce = layui.tinymce

        // 获取轮播图 数据
        http.request('config/list', 'get', {
            page: 1,
            limit: 5
        }, function (res) {
            if (res.data.list.length > 0) {
                var swiperItemHtml = '';
                for (let item of res.data.list) {
                    if (item.name.indexOf('picture') >= 0 && item.value && item.value != "" && item.value != null) {
                        swiperItemHtml +=
                            '<div>' +
                            '<img style="width: 100%;height: 100%;object-fit:cover;" class="swiper-item" src="' + item.value + '">' +
                            '</div>';
                    }
                }
                jquery('#swiper-item').html(swiperItemHtml);
                // 轮播图
                vue.$nextTick(() => {
                    carousel.render({
                        elem: '#swiper',
                        width: '100%',
                        height: '500px',
                        arrow: 'hover',
                        anim: 'fade',
                        autoplay: 'true',
                        interval: '3000',
                        indicator: 'inside'
                    });

                })
                // carousel.render({
                // 	elem: '#swiper',
                // 	width: swiper.width,height:swiper.height,
                // 	arrow: swiper.arrow,
                // 	anim: swiper.anim,
                // 	interval: swiper.interval,
                // 	indicator: "none"
                // });
            }
        });


        // session独取
        let table = localStorage.getItem("userTable");
        http.request(`${table}/session`, 'get', {}, function (data) {
            // 表单赋值
            //form.val("myForm", data.data);
            data = data.data
            for (var key in data) {
                if (key == 'yonghuming') {
                    vue.detail[`${key}`] = data[`${key}`]
                    continue;
                }
                if (key == 'yonghuxingming') {
                    vue.detail[`${key}`] = data[`${key}`]
                    continue;
                }
            }
        });

        // 跨表
        if (http.getParam('corss')) {
            var obj = JSON.parse(localStorage.getItem('crossObj'));
            for (var o in obj) {
                if (o == 'ceshibianhao') {
                    vue.detail[o] = obj[o];
                    vue.ro.ceshibianhao = true;
                    continue;
                }
                if (o == 'ceshimingcheng') {
                    vue.detail[o] = obj[o];
                    vue.ro.ceshimingcheng = true;
                    continue;
                }
                if (o == 'yonghuming') {
                    vue.detail[o] = obj[o];
                    vue.ro.yonghuming = true;
                    continue;
                }
                if (o == 'yonghuxingming') {
                    vue.detail[o] = obj[o];
                    vue.ro.yonghuxingming = true;
                    continue;
                }
                if (o == 'huida1') {
                    vue.detail[o] = obj[o];
                    vue.ro.huida1 = true;
                    continue;
                }
                if (o == 'huida2') {
                    vue.detail[o] = obj[o];
                    vue.ro.huida2 = true;
                    continue;
                }
                if (o == 'huida3') {
                    vue.detail[o] = obj[o];
                    vue.ro.huida3 = true;
                    continue;
                }
                if (o == 'huida4') {
                    vue.detail[o] = obj[o];
                    vue.ro.huida4 = true;
                    continue;
                }
                if (o == 'huida5') {
                    vue.detail[o] = obj[o];
                    vue.ro.huida5 = true;
                    continue;
                }
            }
        }


        // 提交
        form.on('submit(*)', function (data) {
            data = data.field;

            // 数据校验

            // 跨表计算

            // 比较大小

            // 提交数据
            http.requestJson('ceshishuju' + '/add', 'post', data, function (res) {
                debugger
                if (res.code == 0) {
                    alert(res.msg)
                    back();
                }
            });

            return false
        });

    });
</script>
</body>
</html>
